<template>
    <div>
        <VHeader title="我的排名" />
        <div class="title">
            我是神农架林区第 {{info.rank}} 名注册志愿者
        </div>
        <div class="flex flex-space-between preview">
            <div>
                <div><span class="orange">{{info.integral}}</span><sub class="sub"> 个</sub></div>
                <div class="subtitle">积分</div>
            </div>
            <div>
                <div><span class="orange">{{info.service_count}}</span><sub class="sub"> 次</sub></div>
                <div class="subtitle">服务次数</div>
            </div>
            <div>
                <div><span class="orange">{{info.team_count}}</span><sub class="sub"> 个</sub></div>
                <div class="subtitle">参与团队</div>
            </div>
            <div>
                <div><span class="orange">{{info.service_star}}星</span></div>
                <div class="subtitle">我的星级</div>
            </div>
        </div>
        <div class="ranks">
            <div class="rank-title">全区服务排名</div>
            <div class="rank-line first">积分：全区第 <span class="orange">{{info.rank_integral}}</span> 名</div>
            <div class="rank-line">服务次数：全区第 <span class="orange">{{info.rank_count}}</span> 名</div>
        </div>
        <div class="ranks" v-for="team in info.team" :key="team.name">
            <div class="rank-title">{{team.name}}排名</div>
            <div class="rank-line first">积分：全区第 <span class="orange">{{team.rank_integral}}</span> 名</div>
            <div class="rank-line">服务次数：全区第 <span class="orange">{{team.rank_count}}</span> 名</div>
        </div>
    </div>
</template>

<script>
export default {
    data(){
        return {
            info: {}
        }
    },
    methods: {
        async getInfo(){
            let res = await this.$http({
                method: 'api.mine.rank',
            });
            this.info = res.data;
        }
    },
    mounted() {
        this.getInfo();
    }
}
</script>

<style scoped lang="scss">
    .title {
        padding: 0.7rem 0;
        font-size: 150%;
        text-align: center;
    }
    .preview {
        text-align:center;
        border-bottom: 1px solid #CCC;
        background-color:#FFF;
        > div {
            width: 25%;
        }
        .orange {
            color: #ff716d;
            font-size: 120%;
        }
        .subtitle {
            font-size: 120%;
            padding: 0.3rem 0;
        }
        .sub {
            color: #8d9091;
        }
    }
    .ranks {
        font-size: 110%;
        line-height: 120%;
        padding: 0 0.2rem;
        .rank-title {
            border-left: 4px solid #F3A841;
            padding-left: 10px;
            font-size: 120%;
            line-height: 140%;
            margin: 0.2rem 0;
        }
        .rank-line {
            line-height: 140%;
            padding-left: 40px;
        }
        .rank-line.first {
            border-top: 1px solid #CCC;
            padding-top: 0.2rem;
        }
        .orange {
            color: #ff716d;
        }
    }
</style>
